//
//  ViewController.m
//  JKBarStatus
//
//  Created by 王冲 on 2018/11/6.
//  Copyright © 2018年 JK科技有限公司. All rights reserved.
//

#import "ViewController.h"
#import "TestViewController.h"
@interface ViewController ()

/**
 状态栏的颜色
 UIStatusBarStyleDefault 黑色
 UIStatusBarStyleLightContent 白色
 
 */
@property(nonatomic,assign) UIStatusBarStyle barStatus;



@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor blueColor];
    
    self.barStatus = UIStatusBarStyleDefault;
    
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    [btn setTitle:@"黑色" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(click1) forControlEvents:UIControlEventTouchUpInside];
    [btn setBackgroundColor:[UIColor yellowColor]];
    [self.view addSubview:btn];
    
    UIButton *btn2 = [[UIButton alloc]initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame)+50, 100, 100, 100)];
    [btn2 addTarget:self action:@selector(click2) forControlEvents:UIControlEventTouchUpInside];
    [btn2 setTitle:@"白色" forState:UIControlStateNormal];
    [btn2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn2 setBackgroundColor:[UIColor brownColor]];
    [self.view addSubview:btn2];
    
}

#pragma mark 黑色
-(void)click1{
    
    self.barStatus = UIStatusBarStyleDefault;
    [self setNeedsStatusBarAppearanceUpdate];
}
#pragma mark 白色
-(void)click2{
    
    self.barStatus = UIStatusBarStyleLightContent;
    [self setNeedsStatusBarAppearanceUpdate];
}

-(UIStatusBarStyle)preferredStatusBarStyle{
    
    return self.barStatus;
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    TestViewController *test = [[TestViewController alloc]init];
    [self.navigationController pushViewController:test animated:YES];
}


@end
